package com.testing.splogin.mapper;
import com.testing.splogin.model.User;
import org.apache.ibatis.annotations.*;
@Mapper
public interface UserMapper {
@Insert("insert into userinfo(id,username,pwd,nickname,`describe`)"+"values(0,#{uName},#{pwd},#{nick},#{desc}")
    int insertUser(@Param("uName") String username,
                   @Param("pwd") String password,
                   @Param("nick") String nick,
                   @Param("desc") String desc);
@Delete("delete from userinfo where username=#{uName}")
    int deleteUser(@Param("uName") String username);
@Update("update userinfo set nickname=#{nick}  where username=#{uName}")
    int updateUser(@Param("nick") String nickname,
                   @Param("uName") String username);
@Select("select * from userinfo where username=#{uName}")
    User QueryUserByName(@Param("uName") String username);
@Select("select * from userinfo where username=#{uName} and `pwd`=#{pwd}")
    User QueryUserByNameAndPwd(@Param("uName") String username,
                               @Param("pwd") String password);
//1、通过id查询用户的昵称和描述信息
//2、通过id和用户名删除用户
//3、通过id和用户名更新用户昵称
    @Select("select nickname,describe from userinfo where id=#{idno}")
    User QueryUserById(@Param("idno") int idNo);
    @Delete("delete from userinfo where id=#{idNo}")
    int deleteUserById(@Param("idNo") int idNo);
    @Update("update userinfo set nickname=#{niName} where id=#{idNo}")
            int updateUserById(@Param("niName") String nickName,
                               @Param("idNo") int idNo);
}
